﻿<Window x:Class="SnippetBox.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:avalonEdit="clr-namespace:ICSharpCode.AvalonEdit;assembly=ICSharpCode.AvalonEdit"
        Title="SnippetBox Beta" Height="700" Width="1000" Icon="/SnippetBox;component/resources/box_icon.ico" Loaded="Window_Loaded" Closing="Window_Closing">
  <Window.Resources>
    <ResourceDictionary>
      <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="/resourcedictionaries/ListViewItemStyle.xaml"></ResourceDictionary>
        <ResourceDictionary Source="/resourcedictionaries/TreeViewItemStyle.xaml"></ResourceDictionary>
      </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>
  </Window.Resources>

  <Grid>
    <Grid.RowDefinitions>
      <RowDefinition Height="40"></RowDefinition>
      <RowDefinition Height="*"></RowDefinition>
      <RowDefinition Height="20"></RowDefinition>
    </Grid.RowDefinitions>
    <Grid.ColumnDefinitions>
      <ColumnDefinition Width="200"></ColumnDefinition>
      <ColumnDefinition Width="*"></ColumnDefinition>
    </Grid.ColumnDefinitions>
    
    <Border Grid.ColumnSpan="2" BorderBrush="#999999" Background="#E9E9E9" BorderThickness="0,0,0,1">
    </Border>

    <StackPanel Grid.Row="0" Grid.Column="0" Orientation="Horizontal">
      <Button x:Name="btn_addtopic" MinWidth="30" Height="30" HorizontalAlignment="Left" Margin="5,0,5,0" Click="btn_addtopic_Click">
        <StackPanel Orientation="Horizontal">
          <Image Source="/resources/add.png" Height="20" HorizontalAlignment="Left" Margin="0,0,0,0"></Image>
          <TextBlock VerticalAlignment="Center"></TextBlock>
        </StackPanel>
      </Button>
      <Button x:Name="btn_edittopic" MinWidth="30" Height="30" HorizontalAlignment="Left" Margin="0,0,5,0" Click="btn_edittopic_Click" Visibility="Collapsed">
        <StackPanel Orientation="Horizontal">
          <Image Source="/resources/edit.png" Height="20" HorizontalAlignment="Left" Margin="0,0,0,0"></Image>
          <TextBlock VerticalAlignment="Center"></TextBlock>
        </StackPanel>
      </Button>
      <Button x:Name="btn_deletetopic" MinWidth="30" Height="30" HorizontalAlignment="Left" Margin="0,0,5,0" Click="btn_deletetopic_Click" Visibility="Collapsed">
        <StackPanel Orientation="Horizontal">
          <Image Source="/resources/delete.png" Height="20" HorizontalAlignment="Left" Margin="0,0,0,0"></Image>
          <TextBlock VerticalAlignment="Center"></TextBlock>
        </StackPanel>
      </Button>
    </StackPanel>

    <StackPanel Grid.Row="0" Grid.Column="1" Orientation="Horizontal">
      <Button x:Name="btn_addsnippet" MinWidth="30" Height="30" HorizontalAlignment="Left" Margin="0,0,5,0" Click="btn_addsnippet_Click" Visibility="Collapsed">
        <StackPanel Orientation="Horizontal">
          <Image Source="/resources/add.png" Height="20" HorizontalAlignment="Left" Margin="0,0,0,0"></Image>
          <TextBlock VerticalAlignment="Center"></TextBlock>
        </StackPanel>
      </Button>
      <Button x:Name="btn_editsnippet" MinWidth="30" Height="30" HorizontalAlignment="Left" Margin="0,0,5,0" Click="btn_editsnippet_Click" Visibility="Collapsed">
        <StackPanel Orientation="Horizontal">
          <Image Source="/resources/edit.png" Height="20" HorizontalAlignment="Left" Margin="0,0,0,0"></Image>
          <TextBlock VerticalAlignment="Center"></TextBlock>
        </StackPanel>
      </Button>
      <Button x:Name="btn_deletesnippet" MinWidth="30" Height="30" HorizontalAlignment="Left" Margin="0,0,5,0" Click="btn_deletesnippet_Click" Visibility="Collapsed">
        <StackPanel Orientation="Horizontal">
          <Image Source="/resources/delete.png" Height="20" HorizontalAlignment="Left" Margin="0,0,0,0"></Image>
          <TextBlock VerticalAlignment="Center"></TextBlock>
        </StackPanel>
      </Button>
      <Canvas Width="22" Background="Transparent"></Canvas>
      <Button x:Name="btn_savesnippet" MinWidth="30" Height="30" HorizontalAlignment="Left" Margin="0,0,5,0" Click="btn_savesnippet_Click" Visibility="Collapsed">
        <StackPanel Orientation="Horizontal">
          <Image Source="/resources/save.png" Height="20" HorizontalAlignment="Left" Margin="0,3,0,0"></Image>
          <TextBlock VerticalAlignment="Center"></TextBlock>
        </StackPanel>
      </Button>
    </StackPanel>

    <TreeView x:Name="tv_topic" Grid.Row="1" Grid.Column="0" BorderThickness="0" ItemContainerStyle="{DynamicResource ResourceKey=TreeViewItemStyle}" KeyUp="tv_topic_KeyUp" SelectedItemChanged="tv_topic_SelectedItemChanged">
    </TreeView>

    <Border Grid.Row="2" BorderBrush="#CCCCCC" BorderThickness="0,1,0,0">
      <TextBlock x:Name="lbl_messages" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="0,0,5,0" Foreground="#555555"></TextBlock>
    </Border>

    <GridSplitter Grid.Column="0" Grid.Row="1" Grid.RowSpan="2" HorizontalAlignment="Right" ResizeDirection="Columns" Width="2"></GridSplitter>

    <Grid Grid.Row="1" Grid.Column="1" Grid.RowSpan="2">
      <Grid.RowDefinitions>
        <RowDefinition Height="200"></RowDefinition>
        <RowDefinition Height="*"></RowDefinition>
      </Grid.RowDefinitions>

      <Popup x:Name="pop_newtopic" IsOpen="False" Width="250" Height="105" Placement="Center" KeyUp="pop_newtopic_KeyUp">
        <Border BorderBrush="#CCCCCC" Background="#EEEEEE" BorderThickness="2">
          <StackPanel Orientation="Vertical">
            <Border Margin="0,0,0,10" BorderBrush="#CCCCCC" BorderThickness="0,0,0,2">
              <StackPanel Orientation="Horizontal">
                <Label>Add New Topic</Label>
                <Label x:Name="lbl_newtopic_error" FontSize="11" Foreground="Red" VerticalAlignment="Center" HorizontalAlignment="Right"></Label>
              </StackPanel>
            </Border>
            <StackPanel Orientation="Vertical" VerticalAlignment="Center" HorizontalAlignment="Left">
              <TextBox x:Name="tb_newtopic" Width="220" Height="25" Margin="10,0,10,0" BorderThickness="1" BorderBrush="#CCCCCC"></TextBox>
              <StackPanel Orientation="Horizontal" Margin="10,5,10,5" HorizontalAlignment="Right">
                <Button x:Name="btn_newtopic_ok" Width="60" Height="25" Click="btn_addtopic_ok_Click" Margin="0,0,5,0">OK</Button>
                <Button x:Name="btn_newtopic_cancel" Width="60" Height="25" Click="btn_addtopic_cancel_Click">Cancel</Button>
              </StackPanel>
            </StackPanel>
          </StackPanel>
        </Border>
      </Popup>

      <Popup x:Name="pop_edittopic" IsOpen="False" Width="250" Height="105" Placement="Center" KeyUp="pop_edittopic_KeyUp">
        <Border BorderBrush="#CCCCCC" Background="#EEEEEE" BorderThickness="2">
          <StackPanel Orientation="Vertical">
            <Border Margin="0,0,0,10" BorderBrush="#CCCCCC" BorderThickness="0,0,0,2">
              <StackPanel Orientation="Horizontal">
                <Label>Edit Topic</Label>
                <Label x:Name="lbl_edittopic_error" FontSize="11" Foreground="Red" VerticalAlignment="Center" HorizontalAlignment="Right"></Label>
              </StackPanel>
            </Border>
            <StackPanel Orientation="Vertical" VerticalAlignment="Center" HorizontalAlignment="Left">
              <TextBox x:Name="tb_edittopic" Width="220" Height="25" Margin="10,0,10,0" BorderThickness="1" BorderBrush="#CCCCCC"></TextBox>
              <StackPanel Orientation="Horizontal" Margin="10,5,10,5" HorizontalAlignment="Right">
                <Button x:Name="btn_edittopic_ok" Width="60" Height="25" Click="btn_edittopic_ok_Click" Margin="0,0,5,0">OK</Button>
                <Button x:Name="btn_edittopic_cancel" Width="60" Height="25" Click="btn_edittopic_cancel_Click">Cancel</Button>
              </StackPanel>
            </StackPanel>
          </StackPanel>
        </Border>
      </Popup>

      <Popup x:Name="pop_newsnippet" IsOpen="False" Width="250" Height="215" Placement="Center" KeyUp="pop_newsnippet_KeyUp">
        <Border BorderBrush="#CCCCCC" Background="#EEEEEE" BorderThickness="2">
          <StackPanel Orientation="Vertical">
            <Border Margin="0,0,0,10" BorderBrush="#CCCCCC" BorderThickness="0,0,0,2">
              <StackPanel Orientation="Horizontal">
                <Label>Add New Snippet</Label>
              </StackPanel>
            </Border>
            <StackPanel Orientation="Vertical" VerticalAlignment="Center" HorizontalAlignment="Left">
              <TextBox x:Name="tb_newsnippet_name" Width="220" Height="25" Margin="10,0,10,5" BorderThickness="1" BorderBrush="#CCCCCC"></TextBox>

              <TextBox  x:Name="tb_newsnippet_description" Width="220" Height="100" Margin="10,0,10,0" 
                        BorderThickness="1" BorderBrush="#CCCCCC" TextWrapping="Wrap" VerticalScrollBarVisibility="Auto" 
                        HorizontalScrollBarVisibility="Hidden" AcceptsReturn="True" AcceptsTab="True"></TextBox>
              <StackPanel Orientation="Horizontal" Margin="10,5,10,5" HorizontalAlignment="Right">
                <Button x:Name="btn_newsnippet_ok" Width="60" Height="25" Click="btn_addsnippet_ok_Click" Margin="0,0,5,0">OK</Button>
                <Button x:Name="btn_newsnippet_cancel" Width="60" Height="25" Click="btn_addsnippet_cancel_Click">Cancel</Button>
              </StackPanel>
            </StackPanel>
          </StackPanel>
        </Border>
      </Popup>

      <Popup x:Name="pop_editsnippet" IsOpen="False" Width="250" Height="215" Placement="Center" KeyUp="pop_editsnippet_KeyUp">
        <Border BorderBrush="#CCCCCC" Background="#EEEEEE" BorderThickness="2">
          <StackPanel Orientation="Vertical">
            <Border Margin="0,0,0,10" BorderBrush="#CCCCCC" BorderThickness="0,0,0,2">
              <StackPanel Orientation="Horizontal">
                <Label>Edit Snippet</Label>
              </StackPanel>
            </Border>
            <StackPanel Orientation="Vertical" VerticalAlignment="Center" HorizontalAlignment="Left">
              <TextBox x:Name="tb_editsnippet_name" Width="220" Height="25" Margin="10,0,10,5" BorderThickness="1" BorderBrush="#CCCCCC"></TextBox>

              <TextBox  x:Name="tb_editsnippet_description" Width="220" Height="100" Margin="10,0,10,0" 
                        BorderThickness="1" BorderBrush="#CCCCCC" TextWrapping="Wrap" VerticalScrollBarVisibility="Auto" 
                        HorizontalScrollBarVisibility="Hidden" AcceptsReturn="True" AcceptsTab="True"></TextBox>
              <StackPanel Orientation="Horizontal" Margin="10,5,10,5" HorizontalAlignment="Right">
                <Button x:Name="btn_editsnippet_ok" Width="60" Height="25" Click="btn_editsnippet_ok_Click" Margin="0,0,5,0">OK</Button>
                <Button x:Name="btn_editsnippet_cancel" Width="60" Height="25" Click="btn_editsnippet_cancel_Click">Cancel</Button>
              </StackPanel>
            </StackPanel>
          </StackPanel>
        </Border>
      </Popup>

      <Popup x:Name="pop_alert" IsOpen="False" Width="250" MinHeight="100" Placement="Center" KeyUp="pop_newsnippet_KeyUp">
        <Border BorderBrush="#CCCCCC" Background="#EEEEEE" BorderThickness="2">
          <StackPanel Orientation="Vertical">
            <Border Margin="0,0,0,10" BorderBrush="#CCCCCC" BorderThickness="0,0,0,2">
              <StackPanel Orientation="Horizontal">
                <Label x:Name="lbl_alert_header"></Label>
              </StackPanel>
            </Border>
            <StackPanel Orientation="Vertical" VerticalAlignment="Center" HorizontalAlignment="Left">
              <Label Width="230" Margin="10,0,10,0">
                <TextBlock x:Name="lbl_alert_content"></TextBlock>
              </Label>
              <StackPanel Orientation="Horizontal" Margin="10,5,10,5" HorizontalAlignment="Right">
                <Button x:Name="btn_alert_ok" Width="60" Height="25" Click="btn_alert_ok_Click" Margin="0,0,5,0">OK</Button>
                <Button x:Name="btn_alert_cancel" Width="60" Height="25" Click="btn_alert_cancel_Click">Cancel</Button>
              </StackPanel>
            </StackPanel>
          </StackPanel>
        </Border>
      </Popup>

      <ListView x:Name="lv_snippets" Grid.Row="0" BorderThickness="0" ItemContainerStyle="{DynamicResource ResourceKey=ListViewItemStyle}" KeyUp="lv_snippets_KeyUp" SelectionChanged="lv_snippets_SelectionChanged">
        <ListView.View>
          <GridView AllowsColumnReorder="True">
            <GridViewColumn Header="Name" Width="200" CellTemplate="{StaticResource CellTemplateName}"></GridViewColumn>
            <GridViewColumn Header="Date" Width="180" CellTemplate="{StaticResource CellTemplateDate}"></GridViewColumn>
            <GridViewColumn Header="Description" Width="350" CellTemplate="{StaticResource CellTemplateDescription}"></GridViewColumn>
          </GridView>
        </ListView.View>
      </ListView>

      <GridSplitter Grid.Row="0" ResizeDirection="Rows" HorizontalAlignment="Stretch" VerticalAlignment="Bottom" Height="2"></GridSplitter>

      <avalonEdit:TextEditor x:Name="avalonedit" Grid.Row="1" FontFamily="Consolas" FontSize="10pt" HorizontalScrollBarVisibility="Auto" 
                            VerticalScrollBarVisibility="Auto" Margin="0,0,0,0" IsEnabled="False" PreviewKeyDown="avalonedit_PreviewKeyDown">
      </avalonEdit:TextEditor>

    </Grid>
  </Grid>
</Window>
